package com.mayajie.tree;

/**
 * 树的存储结构-双亲表示法
 * @author mayajie
 * @date 2021/10/29
 */
public class ParentStruct {
    class Node<T>{
        T data;
        int parent;

        public Node(T data, int parent) {
            this.data = data;
            this.parent = parent;
        }
    }
    public Node<Character>[] create() {
        Node<Character>[] tree = new Node[8];
        tree[0] = new Node<>('H', -1);
        tree[1] = new Node<>('A', 0);
        tree[2] = new Node<>('C', 0);
        tree[3] = new Node<>('B', 1);
        tree[4] = new Node<>('E', 1);
        tree[5] = new Node<>('G', 4);
        tree[6] = new Node<>('F', 4);
        tree[7] = new Node<>('D', 4);
        return tree;
    }

    public static void main(String[] args) {
        new ParentStruct().create();
    }
}
